<?php

use EasySwoole\DDL\DDLBuilder;
use EasySwoole\DDL\Blueprint\Table;
use EasySwoole\DDL\Enum\Engine;
use EasySwoole\DDL\Enum\Character;

return $result = DDLBuilder::table('admin_login_logs', function (Table $table)
{
    $table->setIfNotExists()->setTableComment('管理员登录日志表')//设置表名称/
    ->setTableEngine(Engine::INNODB)//设置表引擎
    ->setTableCharset(Character::UTF8MB4_GENERAL_CI);//设置表字符集
    $table->colInt('log_id', 10)->setColumnComment('Id')->setIsAutoIncrement()->setIsPrimaryKey();
    $table->colInt('admin_id', 10)->setIsUnsigned()->setDefaultValue(0)->setColumnComment('管理员Id');
    $table->colVarChar('created_ip')->setColumnLimit(200)->setDefaultValue('')->setColumnComment('创建时的IP');
    $table->colVarChar('browser_type')->setColumnLimit(200)->setDefaultValue('')->setColumnComment('创建时浏览器类型');
    $table->colTinyInt('log_status')->setIsUnsigned()->setDefaultValue(1)->setColumnComment('状态[0.失败；1.成功]');
    $table->colVarChar('description')->setColumnLimit(200)->setDefaultValue('')->setColumnComment('描述');
    $table->colVarChar('log_action')->setColumnLimit(200)->setDefaultValue('')->setColumnComment('请求方法');
    $table->colVarChar('log_method')->setColumnLimit(200)->setDefaultValue('')->setColumnComment('请求类型/请求方式');
    $table->colVarChar('request_data')->setColumnLimit(500)->setDefaultValue('')->setColumnComment('请求参数');
    $table->colTinyInt('is_delete')->setIsUnsigned()->setDefaultValue(0)->setColumnComment('是否删除[0：否；1：是]');
    $table->colInt('created_time', 10)->setIsUnsigned()->setDefaultValue(0)->setColumnComment('创建时间');
    $table->colInt('updated_time', 10)->setIsUnsigned()->setDefaultValue(0)->setColumnComment('更新时间');
    $table->indexNormal('admin_id', 'admin_id');//设置索引
    $table->indexNormal('log_status', 'log_status');//设置索引
    $table->indexNormal('is_delete', 'is_delete');//设置索引
});

